﻿<UserControl x:Class="Northwind.UI.WPF.Orders"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <Style TargetType="{x:Type TextBlock}" x:Key="rightAlign" >
            <Setter Property="TextAlignment" Value="Right" />
        </Style>
        <Style TargetType="{x:Type TextBlock}" x:Key="leftAlign" >
            <Setter Property="TextAlignment" Value="Left" />
        </Style>
    </UserControl.Resources>
    <Grid>
        <DataGrid ItemsSource="{Binding Orders}" 
                  AutoGenerateColumns="False">
            <DataGrid.Columns>
                <DataGridTextColumn Header="ID" 
                    Binding="{Binding Model.OrderID}"
                    ElementStyle
                        ="{StaticResource leftAlign}" />
                <DataGridTextColumn Header="Order Date" 
                    Binding="{Binding Model.OrderDate, 
                        StringFormat=d}"
                    ElementStyle
                        ="{StaticResource leftAlign}" />
                <DataGridTextColumn Header="Shipped Date" 
                    Binding="{Binding Model.ShippedDate, 
                        StringFormat=d}"
                    ElementStyle
                        ="{StaticResource leftAlign}" />
                <DataGridTextColumn Header="Total" 
                    Binding="{Binding Total, 
                        StringFormat=c}"
                    ElementStyle
                        ="{StaticResource rightAlign}" />
                <DataGridTemplateColumn Header="Details">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock> 
                                <Hyperlink 
                                    Command="{Binding 
                                        ShowOrderDetailsCommand}"> 
                                     <TextBlock 
                                        Text="Show Details" /> 
                                </Hyperlink> 
                            </TextBlock>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</UserControl>
